package com.sss.hloster0407;

import java.util.*;

public class TestForEach {//增强for循环

	public static void main(String[] args) {
		test01();
	}

	private static void test01() {
		String[] stuArr = { "王云", "凌静涛", "南天华", "雷静" };
		// 传统for 循环遍历
		for (int i = 0; i < stuArr.length; i++) {
			System.out.println(stuArr[i]);
		}
		// 增强for 循环遍历
		for (String stu : stuArr) {
			System.out.println(stu);
		}
		Set nameSet = new HashSet();
		nameSet.add("王云");
		nameSet.add("凌静涛");
		nameSet.add("南天华");
		nameSet.add("雷静");
		// 迭代器遍历
		Iterator it = nameSet.iterator();
		while (it.hasNext()) {
			System.out.println(it.next());
		}
		for (Object stu2 : nameSet) {
			System.out.println((String) stu2);
		}
	}
}
